package com.ruoyi.web.controller.qsng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qsng.domain.KIntegralOrder;
import com.ruoyi.qsng.service.IKIntegralOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 积分排行Controller
 * 
 * @author kanglou
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/qsng/order")
@Api(tags = "pc--积分排行Controller")
public class KIntegralOrderController extends BaseController
{
    @Autowired
    private IKIntegralOrderService kIntegralOrderService;

    /**
     * 查询积分排行列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:order:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询积分排行列表")
    public TableDataInfo list(KIntegralOrder kIntegralOrder)
    {
        startPage();
        List<KIntegralOrder> list = kIntegralOrderService.selectKIntegralOrderList(kIntegralOrder);
        return getDataTable(list);
    }

    /**
     * 导出积分排行列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:order:export')")
    @Log(title = "积分排行", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出积分排行列表")
    public void export(HttpServletResponse response, KIntegralOrder kIntegralOrder)
    {
        List<KIntegralOrder> list = kIntegralOrderService.selectKIntegralOrderList(kIntegralOrder);
        ExcelUtil<KIntegralOrder> util = new ExcelUtil<KIntegralOrder>(KIntegralOrder.class);
        util.exportExcel(response, list, "积分排行数据");
    }

    /**
     * 获取积分排行详细信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:order:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取积分排行详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(kIntegralOrderService.selectKIntegralOrderById(id));
    }

    /**
     * 新增积分排行
     */
    @PreAuthorize("@ss.hasPermi('qsng:order:add')")
    @Log(title = "积分排行", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增积分排行")
    public AjaxResult add(@RequestBody KIntegralOrder kIntegralOrder)
    {
        return toAjax(kIntegralOrderService.insertKIntegralOrder(kIntegralOrder));
    }

    /**
     * 修改积分排行
     */
    @PreAuthorize("@ss.hasPermi('qsng:order:edit')")
    @Log(title = "积分排行", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改积分排行")
    public AjaxResult edit(@RequestBody KIntegralOrder kIntegralOrder)
    {
        return toAjax(kIntegralOrderService.updateKIntegralOrder(kIntegralOrder));
    }

    /**
     * 删除积分排行
     */
    @PreAuthorize("@ss.hasPermi('qsng:order:remove')")
    @Log(title = "积分排行", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除积分排行")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kIntegralOrderService.deleteKIntegralOrderByIds(ids));
    }
}
